const express = require("express");
const compression = require('compression')
const { createProxyMiddleware } = require("http-proxy-middleware");
const path = require("path");
const app = express();  

app.use(compression());
app.use(express.static(path.join(__dirname, "build"), { gzip: false }));


// const url = "http://10.15.111.15:8088";
 const url = "http://10.15.111.15:44545";

app.use(
  "/sdata",
  createProxyMiddleware({
    target: url,
    changeOrigin: true,
  })
);
app.use(
  "/storage_area",
  createProxyMiddleware({
    target: url,
    changeOrigin: true,
  })
);
app.use(
  "/micro-apps",
  createProxyMiddleware({
    target: url,
    changeOrigin: true,
  })
);
app.use(
  "/sdata/ext",
  createProxyMiddleware({
    target: url,
    changeOrigin: true,
  })
);
app.use("/", function (req, res) {
  res.sendFile(path.join(__dirname, "build", "index.html"));
});

app.listen(3000);
